//import 'package:amap_location_fluttify/amap_location_fluttify.dart';
import 'package:fluro/fluro.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:quintesson/state/login_state.dart';

import 'const.dart';
import 'routes.dart';

///启动
void main() {
  WidgetsFlutterBinding.ensureInitialized();

  ///初始化并配置路由
  Routes.configureRoutes(Router());

  runApp(MultiProvider(
    providers: [
      ChangeNotifierProvider(create: (context) => LoginState(Const.UNLOGIN))
    ],
    child: MaterialApp(
        theme: ThemeData(
            appBarTheme: AppBarTheme(
          elevation: 0,
          color: Colors.transparent,
          textTheme:
              TextTheme(subtitle1: TextStyle(color: Const.gold, fontSize: 16)),
          iconTheme: IconThemeData(color: Const.gold),
          actionsIconTheme: IconThemeData(color: Const.gold),
        )),
        onGenerateRoute: Routes.router.generator),
  ));
}

/// 根界面 决定跳转的页面
class PageRoot extends StatefulWidget {
  PageRoot({Key key}) : super(key: key);

  @override
  State<StatefulWidget> createState() => PageRootState();
}

class PageRootState extends State<PageRoot> {
  String result;

  @override
  void initState() {
    super.initState();

    Future.delayed(Duration(seconds: 0), () {
      intentMain();
    });
  }

  intentMain() async {
    String route = '${Routes.mainPage}';
    Routes.router.navigateTo(context, route,
        replace: true, transition: TransitionType.fadeIn);
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      color: Colors.transparent,
    );
  }
}
